/**
 * 从localStorage 去对应接口数据
 * @param key
 * @param defaultValue
 */
export const localStorageGetItem = <T = unknown>(key: string, defaultValue?: T): T => {
  const loginParamData = localStorage.getItem(key)
  return loginParamData ? JSON.parse(loginParamData) : defaultValue
}

/**
 * 将接口数据存到localStorage
 * @param key
 * @param value
 */
export const localStorageSetItem = <T>(key: string, value: T) => {
  localStorage.setItem(key, JSON.stringify(value))
}

/**
 * 从localStorage删除对应数据
 * @param key
 */
export const localStorageDelItem = (key: string) => {
  localStorage.removeItem(key)
}
